package good

import (
	"api/pb/good"
	"context"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateGoodLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUpdateGoodLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateGoodLogic {
	return &UpdateGoodLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UpdateGoodLogic) UpdateGood(req *types.Good) (*types.Empty, error) {
	_, err := l.svcCtx.GoodRpc.UpdateGood(l.ctx, &good.GoodInfo{Id: req.Id, Name: req.Name, Price: req.Price})
	return &types.Empty{}, err
}
